<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>网易云音乐</title>
  </head>
  <body>
    <h1>网易云音乐</h1>

    <script>
      // 1.xhr 网络请求
      const xhr = new XMLHttpRequest()
      xhr.onreadystatechange = function () {
        if (xhr.readyState === XMLHttpRequest.DONE) {
          console.log(JSON.parse(xhr.responseText))
        }
      }
      xhr.open('get', 'http://localhost:8000/users/list')
      xhr.send()

      // 2.fetch 网络请求
      fetch('http://localhost:8000/users/list').then(async res => {
        const result = await res.json()
        console.log(result)
      })
    </script>
  </body>
</html>
